package vues;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;

import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JPanel;

import modele.ModeleP;

@SuppressWarnings("serial")
public class ScreenPane extends JPanel {
	private ModeleP myMod;
    public ScreenPane(ModeleP myMod){
    	this.myMod=myMod;
    	this.setSize(new Dimension(150, 200));
        this.setPreferredSize(new Dimension(150, 200));
        this.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
    }
    protected void paintComponent(Graphics g) {
    	ImageIcon icon = new ImageIcon("msc"+System.getProperty("file.separator")+System.getProperty("file.separator")+"img"+System.getProperty("file.separator")+System.getProperty("file.separator")+"default.jpg");
    	
		int w = getWidth();
		int h = getHeight();
		g.fillRect(0, 0, w, h);
		if((myMod.getAlbum()!=null && myMod.getAlbum().getImage().isEmpty())){
			icon=new ImageIcon(myMod.getAlbum().getImage());
		}
		Image i=icon.getImage();
		g.drawImage(i, 200, 150, this);
    }
}
